<!doctype html>
<html lang="en">
<head>
<title>设备备品配件领料记录</title>
	<meta name="keywords" content="keyword1,keyword2,keyword3">
	<meta name="description" content="载具清洗">
	<meta name="content-type" content="text/html; charset=UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" type="text/css" href="../../script/js/layui/css/layui.css" media="all">
	<script type="text/javascript" src="../../script/js/layui/layui.js"></script>
	<script type="text/javascript" src="../../script/js/vue.min.js"></script>
	<script type="text/javascript" src="../../script/js/jquery-1.9.1.min.js"></script>
	<script type="text/javascript" src="../../script/js/vue-resource.min.js"></script>
</head>
<body id="production" align="center">
<form class="layui-form layui-form-pane">
	 <fieldset class="layui-elem-field layui-field-title">
		<legend><font color="white">设备备品配件领料记录 </font></legend>
		<div class="layui-form-item">
			<!-- <div class="layui-inline">
					<label class="layui-form-label" style="width:130px;"><span class="layui-badge-dot layui-bg-orange"></span>&nbsp; &nbsp;物料编码</label>
					<div class="layui-input-inline">
						<input type="text" class="layui-input" id="toolId" v-model="record.CODE" @keyDown="getToolInfoByCode" placeholder="请扫描物料条码">
					</div>
			</div> -->
		</div >
		
	 </fieldset>
	 

<div id="confirmReceiveDiv" style="display: none;">
<form class="layui-form layui-form-pane">
 <fieldset class="layui-elem-field layui-field-title">
			<div class="layui-form-item" align="center">
				<div class="layui-inline" style="color:gray;">
					<label  class="layui-form-label"  style="width:230px;"><span class="layui-badge-dot layui-bg-orange"></span>&nbsp; &nbsp; 物料编码</label>
					<div class="layui-input-inline">
				    	<input type="text" class="layui-input" id="reMakeNum" required="required" readonly="readonly"></textarea>
				    </div>
				</div>
			
				<div class="layui-inline" style="color:gray;" >
					<label  class="layui-form-label"  style="width:230px;"><span class="layui-badge-dot layui-bg-orange"></span>&nbsp; &nbsp; 物料名称</label>
					<div class="layui-input-inline">
				    	<input type="text" class="layui-input" id="ZAIJUCODE" required="required" readonly="readonly" ></textarea>
				    </div>
				</div>
				
				<div class="layui-inline" style="color:gray;">
					<label  class="layui-form-label"  style="width:230px;"><span class="layui-badge-dot layui-bg-orange"></span>&nbsp; &nbsp; 库存数量</label>
					<div class="layui-input-inline">
				    	<input type="text" class="layui-input" id="WLNUMBERS" required="required" readonly="readonly"></textarea>
				    </div>
				</div>
				
				
				<div class="layui-inline" style="color:gray; display:none;" >
					<label  class="layui-form-label"  style="width:230px;"><span class="layui-badge-dot layui-bg-orange"></span>&nbsp; &nbsp; 领用数量(隐藏)</label>
					<div class="layui-input-inline">
				    	<input type="text" class="layui-input" id="YCLYNUMBERS" required="required" ></textarea>
				    </div>
				</div>
				
				<div class="layui-inline" style="color:gray;">
					<label  class="layui-form-label"  style="width:230px;"><span class="layui-badge-dot layui-bg-orange"></span>&nbsp; &nbsp; 领用数量</label>
					<div class="layui-input-inline">
				    	<input type="text" class="layui-input" id="LYNUMBERS" required="required" ></textarea>
				    </div>
				</div>
				
				<div class="layui-inline" style="color:gray;">
					<label  class="layui-form-label"  style="width:230px;"><span class="layui-badge-dot layui-bg-orange"></span>&nbsp; &nbsp; 领用人</label>
					<div class="layui-input-inline">
				    	<input type="text" class="layui-input" id="LYUSERNAME" required="required" readonly="readonly"></textarea>
				    </div>
				</div>
				
				<div class="layui-inline" style="color:gray;">
					<label  class="layui-form-label"  style="width:230px;"><span class="layui-badge-dot layui-bg-orange"></span>&nbsp; &nbsp; 领用时间</label>
					<div class="layui-input-inline">
				    	<input type="text" class="layui-input" id="LYTIME" required="required" readonly="readonly"></textarea>
				    </div>
				</div>
				
				<div class="layui-inline" style="color:gray;">
					<label  class="layui-form-label"  style="width:230px;"><span class="layui-badge-dot layui-bg-orange"></span>&nbsp; &nbsp; 领用车间</label>
					<div class="layui-input-inline">
				    	<input type="text" class="layui-input" id="LYORG" required="required" readonly="readonly"></textarea>
				    </div>
				</div>
				
				<div class="layui-inline" style="color:gray;">
					<label  class="layui-form-label"  style="width:230px;"><span class="layui-badge-dot layui-bg-orange"></span>&nbsp; &nbsp; 领用工序</label>
					<div class="layui-input-inline">
				    	<input type="text" class="layui-input" id="LYPROCESS" required="required" readonly="readonly"></textarea>
				    </div>
				</div>
				
				<div class="layui-inline" style="color:gray;">
					<label  class="layui-form-label"  style="width:230px;"><span class="layui-badge-dot layui-bg-orange"></span>&nbsp; &nbsp; 领用设备</label>
					<div class="layui-input-inline">
				    	<input type="text" class="layui-input" id="LYEQUIPMENT" required="required" readonly="readonly"></textarea>
				    </div>
				</div>
				
				<div class="layui-inline" style="color:gray;">
					<label  class="layui-form-label"  style="width:230px;"><span class="layui-badge-dot layui-bg-orange"></span>&nbsp; &nbsp; 领用说明</label>
					<div class="layui-input-inline">
				    	<input type="text" class="layui-input" id="LYREMARKS" required="required" readonly="readonly"></textarea>
				    </div>
				</div>
				
				
				<div class='layui-inline'>
				<label  class="layui-form-label"  style="width:230px;"><span class="layui-badge-dot layui-bg-orange"></span>&nbsp; &nbsp; 审核结果</label>
				<div class="layui-input-inline" style="background-color:#ffffff; height: 38px; width:430px; font-size:0 ; ">
				<input type="radio" name="sex" value="passed" title="通过" checked>
				<input type="radio" name="sex" value="Notthrough" title="不通过" >
				</div>
				</div>
				
				<!--  <div class="layui-form-item layui-form-text">
					 <label class="layui-form-label" style="width:460px;"><span class="layui-badge-dot layui-bg-orange"></span>&nbsp; &nbsp;领用说明</label>
					 <div class="layui-input-block">
					 <input type="text" class="layui-input" id="LYREMARKS" required="required" readonly="readonly" style="width:460px; height:100px;"></textarea>
					 </div>
					    
  				</div>  -->
				
			</div>
</fieldset>
	
</form>
</div>


	<!-- <div class="layui-form-item">
		<button type="button"  class="layui-btn" @click="saveToolCleanRecord">提交</button>
		&nbsp;&nbsp;&nbsp;&nbsp;
		<button type="reset" class="layui-btn" click="reset">重置</button>
	</div> -->
	<script type="text/html" id="remakeReceiveAction">
	    <a class="layui-btn layui-btn-xs" lay-event="yes" {{ d.JLSTATUS == '待审核' ? "" : "style='display\:none'"}}">审核</a>
	</script>
	<table class="layui-hide" id="efficiencyTable" lay-filter="remakeReceiveFilter"></table>
	
</form>
<script type="text/javascript">
var lastresult = true;
var zjname = "";
var vm = new Vue({
	el : "#production",
	data : {
		record:{},
		sels:[]
	},
	init:function(){
		var _self = this;
  		layui.use(['layer'], function(){
  			layer = layui.layer;
        });
      	 this.$nextTick(function() {
				this.$http.post("../../SparepartsRecord/InquireallRecord",{},{emulateJSON: true}).then(function(res){
					if(res.ok){
						_self.tableData = res.body.Stocks;
						_self.$options.methods.renderTable(_self,res.body.Stocks);
					}
				});
		 }); 
		 
	},
	methods: {
		reset:function(){
            window.location.reload();
		}
        ,vueAlert:function(msg){
            layui.use(['form'], function(){
                var layer = layui.layer;
                layer.msg(msg,{icon:6,time:2000});
            });
        },
        renderTable: function(_self,data){
			layui.use(['form','table','laydate'], function(){
				  var table = layui.table;
				  var form = layui.form;
				  
				  table.render({
				    elem: '#efficiencyTable'
				    ,height: 'full-60'
				    ,cols: [[ //标题栏
				       {fixed:'left',type:'numbers',title:'序号'}
				      ,{fixed:'left',field: 'WLCODE', title: '物料编码',width:140}
				      ,{field: 'WLNAME', title: '物料名称',minWidth:120,width:120, align:'center' }
				      ,{field: 'MODEL', title: '型号/规格',minWidth:140,width:140,align:'center'}
				      //,{field: 'WLNUMBERS', title: '库存数量', width:90,align:'center'}
				      ,{field: 'LYNUMBERS', title: '领用数量', width:90,align:'center'}
				      ,{field: 'COMPANY', title: '单位', width:90,align:'center'}
				      ,{field: 'ORGNAME', title: '领用车间', width:100,align:'center'}
				      ,{field: 'GXNAME', title: '领用工序', width:100,align:'center'}
				      ,{field: 'SBNAME', title: '领用设备', width:200,align:'center'}
				      ,{field: 'VALUE', title: '储位', width:80,align:'center'}
				      ,{field: 'YHNAME', title: '领用人', width:120,align:'center'}
				      ,{field: 'RKTIME', title: '领用时间', minWidth: 140,width:190,align:'center'}
				      ,{field: 'REMARKS', title: '领用说明', minWidth: 100,align:'center'}
				      ,{field: 'JLSTATUS', title: '领料单状态', minWidth: 100,align:'center'}
				      ,{fixed: 'right',title:'操作', align:'center', toolbar: '#remakeReceiveAction'}
				    ]]
				    ,data:data
				    ,page: true //是否显示分页
				    ,limits: [10, 20, 50]
				    ,limit: 15 //每页默认显示的数量
				  });
				  //监听工具条
					table.on('tool(remakeReceiveFilter)', function(obj){ //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
						var row = obj.data //获得当前行数据
							,layEvent = obj.event; //获得 lay-event 对应的值
						if(layEvent == 'yes'){
							_self.openConfirmReceiveWindow(row,_self);
						}else if(layEvent == 'no'){
							_self.refuse(row,_self,obj);
						}
					});
				  
				});
		}
		,openConfirmReceiveWindow:function(data,_self){
			var indexReceiveWindow = layer.open({
				type : 1,
				title : '设备备品配件领料确认单',
				id : 'sssss',
				shadeClose : true,
				skin: 'layui-layer-lan',
				shade : 0.8,
				area : [ '60%', '65%' ],
				content : $('#confirmReceiveDiv')
				,btn: ['确认', '取消']
				,btnAlign: 'c'
			  	,yes: function(index, layero){
			  		
			  	  var Radio = $("input[name='sex']:checked").val();			//获取审核结果的值
			  	  var test1 = "";
			  	  if(Radio == "Notthrough"){
			  		test1 = "不通过";
			  	  }else if(Radio == "passed"){
			  		test1 = "通过";
			  	  }
				  
			  	var Collars = document.getElementById("LYNUMBERS").value;  //获取领用数量的值;

			  	var YCCKNUMBERS = document.getElementById("YCLYNUMBERS").value;  //获取领用数量的值;
			  	
	                    layer.confirm("确定"+test1+"？", {icon: 5, title:'提示'}, function(index){
	                        _self.$nextTick(function() {
	                            _self.$http.post("../../SparepartsRecord/SparepartsRecordexamine",{
	                            	KCNUMBERS : _self.number,
	                            	CKNUMBERS : Collars,
	                            	YCCKNUMBERS	:YCCKNUMBERS,
	                            	MATERIEL : data.WLID,
									WLLYJL : data.JLID,
									RESULTS : Radio
									
								},{emulateJSON: true}).then(function(resData){
									 
									layer.msg("领用申请已审核！");
									window.setTimeout(function() {
										window.location.reload();
								        }, 1000);
	                            });
	                        });
	                        layer.close(index);
	                        layer.close(indexReceiveWindow);
	                    });
			  		
			  		
			    	
			  	}
				,btn2: function(index, layero){
			    	//按钮【按钮二】的回调
			    	//return false 开启该代码可禁止点击该按钮关闭
			    	_self.clearReceiveForm();
			  	}
			  	,cancel: function(){ 
			    	//右上角关闭回调
			    	//return false 开启该代码可禁止点击该按钮关闭
			    	_self.clearReceiveForm();
			  	}
			  	,success: function(layero, index){
			  		
			  		$.ajax({
					    url: "../../SparepartsRecord/SumMaterielsresult",
					    type: 'POST',
					    async: false,
					    data: {
					    	toolCode:data.WLCODE
						},
					    dataType: 'json',
						success: function(data) {
						   if(data.result){										   	   
							   _self.number = data.sumnumbers[0].QTYS;
						   	   
						   }else{
						       layer.msg("处理失败");
						   }
						}
					});
			  		
			    	$("#reMakeNum").val(data.WLCODE);
			    	$("#ZAIJUCODE").val(data.WLNAME);
			    	$("#WLNUMBERS").val(_self.number);
			    	$("#LYNUMBERS").val(data.LYNUMBERS);
			    	$("#YCLYNUMBERS").val(data.LYNUMBERS);
			    	$("#LYUSERNAME").val(data.YHNAME);
			    	$("#LYTIME").val(data.RKTIME);
			    	$("#LYORG").val(data.ORGNAME);
			    	$("#LYPROCESS").val(data.GXNAME);
			    	$("#LYEQUIPMENT").val(data.SBNAME);
			    	$("#LYREMARKS").val(data.REMARKS);
			    	
			  	}
			});
		}
		,clearReceiveForm:function(){
			$("#reMakeNum").val('');
			$("#confirmReceiveNum").val('');
		}
        
	}
});

//$("#toolId")[0].select();
</script>
</body>
</html>
